import request from '@/utils/request';
import { IotCategoryQuery, IotCategoryForm, IotCategoryVO } from './types';
import { AxiosPromise } from 'axios';

// 查询设备品类列表
export function listCategory(query: IotCategoryQuery): AxiosPromise<IotCategoryVO[]> {
  return request({
    url: '/system/iot/category/list',
    method: 'get',
    params: query
  });
}

// 查询设备品类详细
export const getCategory = (categoryId: string | number): AxiosPromise<IotCategoryVO> => {
  return request({
    url: '/system/iot/category/' + categoryId,
    method: 'get'
  });
};

// 新增设备品类
export const addCategory = (data: IotCategoryForm) => {
  return request({
    url: '/system/iot/category',
    method: 'post',
    data: data
  });
};

// 修改设备品类
export const updateCategory = (data: IotCategoryForm) => {
  return request({
    url: '/system/iot/category',
    method: 'put',
    data: data
  });
};

// 删除设备品类
export const delCategory = (categoryId: string | number | Array<string | number>) => {
  return request({
    url: '/system/iot/category/' + categoryId,
    method: 'delete'
  });
};


// 获取字典选择框列表
export function optionselect(): AxiosPromise<SelectDataOption[]> {
  return request({
    url: '/system/iot/category/optionselect',
    method: 'get'
  });
}
